#include<bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1e5 + 5;
int T, n, m, L, V;
int d[N], v[N], a[N], p[N];
int recordersToDelete;
float whenToV[N];
vector<int> Ps[N]; //record the cars recorder records
set<int> highSpeedCars;

void initWhenToV(int i){
    int l = 0;
    /*record when the car's speed get to V:
    if none, record 0;
    if ahead/back, record l;
    if all, record -1;*/
        if (a[i] == 0){
            if (v[i] > V) whenToV[i] = -1;
            else whenToV[i] = 0;
        }else{
            l = (V * V - v[i] * v[i]) / (2 * a[i]);
            if (l == 0){
                if (a[i] > 0) whenToV[i] = -1;
                else whenToV[i] = 0;
            }else if (l < 0){
                if (v[i] > V) whenToV[i] = -1;
                else whenToV[i] = 0;
            }else{
                if (d[i] + l >= L) whenToV[i] = 0;
                else whenToV[i] = d[i] + l;
            }
        }
    return;
}

void dealWithPs(int i){
    const int pNow = p[i];
    for (int j = 1; j <= n; j++){
        if (whenToV[j] != 0 && whenToV[j] != -1){
            if (a[j] < 0){
                if (d[j] <= pNow && whenToV[j] > pNow){
                    Ps[i].push_back(j);
                    highSpeedCars.insert(j);
                }
            }else{
                if (whenToV[j] < pNow){
                    Ps[i].push_back(j);
                    highSpeedCars.insert(j);
                }
            }
        }else if (whenToV[j] == -1){
            Ps[i].push_back(j);
            highSpeedCars.insert(j);
        }
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> T;
    while (T--){
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; i++){
            cin >> d[i] >> v[i] >> a[i];
            initWhenToV(i);
        }
        for (int i = 1; i <= m; i++){
            cin >> p[i]; //the recorder
            dealWithPs(i);
        }
        cout << highSpeedCars.size() << ' ';
        for (int i = 1; i <= m; i++){
            int isLeave = 1;
            for (auto j : Ps[i]){
                if (highSpeedCars.count(j)){
                    isLeave = 0;
                    highSpeedCars.erase(j);
                }
            }
            if (isLeave) recordersToDelete++;
        }
        cout << recordersToDelete << '\n';
    }

    return 0;
}
